package BLC

import (
	"flag"
	"fmt"
	"log"
	"os"
)

func (cli *Client) printChainCmd(printChainCmd *flag.FlagSet) {

	err := printChainCmd.Parse(os.Args[2:])
	if err != nil {
		log.Panicf("parse cmd of print Chain Cmd failed! %v\n ", err)
	}
	//输出链信息
	if printChainCmd.Parsed() {
		cli.tPrintBlockChain()
	}

}

//输出区块链信息
func (cli *Client) tPrintBlockChain() {
	if dbExists() == false {
		fmt.Println("数据库不存在---")
		os.Exit(1)
	}
	blockChain := GetBlockChainObj()
	defer blockChain.CloseDB()
	blockChain.PrintBlockChain()
}
